package com.example.task1.ui.AllService.logistics;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.example.task1.R;
import com.example.task1.bean.LogisticsComplaintBean;
import com.example.task1.ui.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

public class LogisticsComplaintAdapter extends BaseAdapter<LogisticsComplaintBean.RowsDTO> {
    private List<LogisticsComplaintBean.RowsDTO> data = new ArrayList<>();

    private Context context;
    private TextView tvContent;
    private TextView tvOrder;
    private TextView tvTime;

    public LogisticsComplaintAdapter(Context context) {
        this.context = context;
    }

    public void setData(List<LogisticsComplaintBean.RowsDTO> rows) {
        int size = data.size();
        data.addAll(rows);
        notifyItemInserted(size);
    }

    @Override
    protected int getLayout() {
        return R.layout.logisticscomplaint;
    }

    @Override
    protected Context getContext() {
        return context;
    }

    @Override
    protected List<LogisticsComplaintBean.RowsDTO> getData() {
        return data;
    }

    @Override
    protected void onBind(myHolder holder, LogisticsComplaintBean.RowsDTO date) {
        tvContent.setText(date.getDescription());
        tvOrder.setText("订单号：" + date.getInfoNo());
        tvTime.setText("---" + date.getCreateTime());
    }

    @Override
    protected void holder(View itemView) {
        initView(itemView);
    }

    private void initView(View itemView) {
        tvContent = (TextView) itemView.findViewById(R.id.tv_content);
        tvOrder = (TextView) itemView.findViewById(R.id.tv_order);
        tvTime = (TextView) itemView.findViewById(R.id.tv_time);
    }
}
